/**
 * 表单验证
 * 
 * @param {Object} rules 验证字段的规则
 * @param {Object} messages 验证字段的提示信息
 * 
 */

import basic from './basic.js';
var actmodel = new basic();
actmodel.do = "integral_exchange"
actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["createtime", "desc"]] ;
  }
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
    para["plugin"] = "integral"
  }
  else {
    this.wherepara["op"] = "offset"
    this.wherepara["plugin"] = "integral"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}
actmodel.getwqint = function () {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      showLoading: false,
      'data':  {  op: "getwqint",plugin:'integral' },
      'method': "post",
      success: function (res) {
        var reslutmodel = res.data.data;
        resolve(reslutmodel);
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    },false);
  })
} 
actmodel.exchange = function (model) {
  var app = getApp();
  return new Promise((resolve, reject) => {
    app.util.request({
      'url': 'entry/wxapp/'+actmodel.do,
      showLoading: false,
      'data':  {  op: "exchange",plugin:'integral' ,model:JSON.stringify(model)},
      'method': "post",
      success: function (res) {
        var reslutmodel = res.data.data;
        resolve(reslutmodel);
      },
      fail: function (res) {
        resolve({ status: -1, "message": "操作失败2" });
      },
      complete: function () {
      }
    },false);
  })
} 

module.exports = actmodel;